<!DOCTYPE html>
<html>
<!-- head -->
{include file="common/page/head"}
<link rel="stylesheet" href="__app__/admin/view/StoreGoods/editGoods/editGoods.css" />
<body>
<!---------------- 编辑商品 ------------------->
<!-- 页头 -->
{include file="common/page/header"}
<!-- jsfiles -->
{include file="common/page/jsfiles"}
<link href="__static__/js/umeditor/themes/default/css/umeditor.min.css" type="text/css" rel="stylesheet">
<script type="text/javascript" charset="utf-8" src="__static__/js/umeditor/third-party/template.min.js"></script>
<script type="text/javascript" charset="utf-8" src="__static__/js/umeditor/umeditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__static__/js/umeditor/umeditor.min.js"></script>
<script type="text/javascript" src="__static__/js/umeditor/lang/zh-cn/zh-cn.js"></script>
<!-- 主体 -->
<div class="content container-fluid{if $leftBarScale eq '1'} scale{/if}">
    <div class="row">
        <div class="col-md-2 left-section">
            <!-- 左导航菜单 -->
            {include file="common/page/menu"}
        </div>
        <div class="col-md-10 right-section">
            <!--内容区域-->
            <h3><i class="icon iconfont">{$Think.session.currentMenu.icon}</i>编辑商品</h3>
            <div class="inner-section row">
                <form role="form"  method="post" id="myForm"  enctype="multipart/form-data">
                    <table class="table table-striped table-hover table-bordered table-base">
                        <tr>
                            <td class="td1"><label>分类</label></td>
                            <td class="td2">
                            	<div class="category-list row">
                            		{foreach $cateList as $cate}
                            			<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 category">{$cate.name}</div>
                            		{/foreach}
                            	</div>
                            </td>
                            <td class="td3"></td>
                        </tr>
                        <tr>
                            <td class="td1"><label>多规格模板</label></td>
                            <td class="td2">
                            	<select class="form-inline" name="tid" id="tid" disabled>
                            		<option value="" {if $goods.standard eq '0'}selected{/if}>统一规格</option>
                            		{if $goods.standard eq '1' && $tidDeleted eq '1'}
                            		<option class="old-tid" value="{$goods.tid}" selected>模板已删除</option>
                            		{/if}
                            		{foreach $templateList as $template}
                            		<option value="{$template.id}" {if $goods.standard eq '1' && $goods.tid eq $template.id}selected{/if}>{$template.name}</option>
                            		{/foreach}
                            	</select>
                            	<a class="reset-property" href="javascript:;">重新选择</a>
                            	<input type="hidden" name="is_reset" id="is_reset" value="0">
                            	<input type="hidden" name="standard" id="standard" value="{$goods.standard}">
                            	<input type="hidden" name="propertyGroups" id="propertyGroups" value="">
                            </td>
                            <td class="td3"></td>
                        </tr>
                        <tr class="property-tr {if !$propertyGroups}hidden{/if}">
                            <td class="td1"><label>商品属性</label></td>
                            <td class="td2">
                             	<div class="property-group-wrap">
                                       {foreach $propertyGroups as $group}
                                       <div class="property-group">
                                           {foreach $group.propertyList as $property}
	                                       <span class="span property">
	                                           <span  class="property-name">{$property->name}</span>
	                                           <span class="property-value">【{$property->value}】</span>
	                                       </span>
	                                       {/foreach}
	                                       <span class="span" data-gpid="{$group.id}">
	                                           <span>原价</span>
	                                           <input type="text" class="oriprice" value="{$group.ori_price}">
	                                       </span>
	                                       <span class="span" data-gpid="{$group.id}">
	                                           <span>现价</span>
	                                           <input type="text" class="price" data-price="{$group.price}" value="{$group.price}">
	                                       </span>
	                                       <span class="span" data-gpid="{$group.id}">
	                                           <span>库存</span>
	                                           <input type="text" class="inventory" value="{$group.inventory}">
	                                       </span>
                                           <a class="btn btn-danger btn-xs delete" href="javascript:;" data-gpid="{$group.id}">删除</a>
                                       </div>
                                       {/foreach}
                             </div>
                             <div class="add-property-group-wrap">
                                 <span class="property-group-action">
                                 	<a class="btn btn-primary btn-sm property-group-add" href="javascript:;">添加</a>
                                 	<span class="property-group-add-tips">(添加新规格请保证与原规格属性内容数目一致)</span>
                                 </span>
                             </div>
                            </td>
                            <td class="td3 property-info"></td>
                        </tr>
                        <tr>
                            <td class="td1"><label><span class="must-tag">*</span>商品名称</label></td>
                            <td class="td2"><input type="text" value="{$goods.name}" id="name" name="name" placeholder="商品名称"></td>
                            <td class="td3"></td>
                        </tr>
                        
                        <tr id="image_type">
                            <td class="td1"><label for="imgurl"><span class="must-tag">&nbsp;&nbsp;</span>主图更新</label></td>
                            <td class="td2">
                                <input type="hidden" name="prevurl" value="{$goods.img_url}">
                                <input class="imgurl form-control"  accept="image/*" value="" title="支持jpg、jpeg、gif、png格式，文件小于5M" tabindex="3" type="file" id="imgurl"name="imgurl" size="3">
                                <img src="../../{$goods.thumb}" style="height: 40px;"  title="缩略图" >
                                <!---是否重新上传图片标识 0未更新，1更新图片-->
                                <input type="hidden" id="imgFlag" name="imgFlag" value="0">
                            </td>
                            <td class="td3"></td>
                        </tr>
                        
                        <tr>
                            <td class="td1"><label><span class="must-tag">&nbsp;&nbsp;</span>辅图更新</label></td>
                            <td class="td2">
                                <div class="side-image-wrap">
                                    <input type="hidden" id="imgFlag1" name="imgFlag1" value="0" class="imgFlag">
                                    <input type="file" name="sideImg1" class="side-image form-control" accept="image/*" value="" title="支持jpg、jpeg、gif、png格式，文件小于5M">
                                    {if $sideImg1}
                                    <input type="hidden" name="prevSideImg1" value="{$sideImg1.img_url}">
                                    <input type="hidden" name="sid1" value="{$sideImg1.id}">
                                    <img src="../../{$sideImg1.thumb}" class="thumb" style="height: 40px;"  title="缩略图" >
                                    <a class="delete-slide-image btn btn-danger btn-xs">删除</a>
                                    {/if}
                                </div>

                                <div class="side-image-wrap">
                                    <input type="hidden" id="imgFlag2" name="imgFlag2" value="0" class="imgFlag">
                                    <input type="file" name="sideImg2" class="side-image form-control"  accept="image/*" value="" title="支持jpg、jpeg、gif、png格式，文件小于5M">
                                    {if $sideImg2}
                                    <input type="hidden" name="prevSideImg2" value="{$sideImg2.img_url}">
                                    <input type="hidden" name="sid2" value="{$sideImg2.id}">
                                    <img src="../../{$sideImg2.thumb}" class="thumb" style="height: 40px;"  title="缩略图" >
                                    <a class="delete-slide-image btn btn-danger btn-xs">删除</a>
                                    {/if}

                                </div>

                                <div class="side-image-wrap">
                                    <input type="hidden" id="imgFlag3" name="imgFlag3" value="0" class="imgFlag">
                                    <input type="file" name="sideImg3" class="side-image form-control"  accept="image/*" value="" title="支持jpg、jpeg、gif、png格式，文件小于5M">
                                    {if $sideImg3}
                                    <input type="hidden" name="prevSideImg3" value="{$sideImg3.img_url}">
                                    <input type="hidden" name="sid3" value="{$sideImg3.id}">
                                    <img src="../../{$sideImg3.thumb}" class="thumb" style="height: 40px;"  title="缩略图" >
                                    <a class="delete-slide-image btn btn-danger btn-xs">删除</a>
                                    {/if}
                                </div>
                            </td>
                            <td class="td3"></td>
                        </tr>
                        <tr>
                            <td class="td1"><label for="price"><span class="must-tag">*</span>标准价格</label></td>
                            <td class="td2"><input type="text" id="price" name="price" value="{$goods.price}" placeholder="标准价格"></td>
                            <td class="td3"></td>
                        </tr>
                        <tr>
                            <td class="td1"><label for="ori_price"><span class="must-tag">*</span>商品原价</label></td>
                            <td class="td2">
                                <input type="text" id="ori_price" name="ori_price" value="{$goods.ori_price}" placeholder="商品原价"></td>
                            <td class="td3"></td>
                        </tr>
                        <tr>
                            <td class="td1"><label for="price_tag"><span class="must-tag">*</span>商品优惠</label></td>
                            <td class="td2"><input type="text" id="price_tag" name="price_tag"  value="{$goods.ori_price}" placeholder="累计购买数量">
                            <input type="text" id="price_tag" name="price_tag"  value="{$goods.ori_price}" placeholder="优惠力度"></td>
                            <td class="td3"></td>
                        </tr>
                        <tr class="hidden">
                            <td class="td1"><label for="price_tag"><span class="must-tag">*</span>价格标签</label></td>
                            <td class="td2"><input type="text" id="price_tag" name="price_tag" value="{$goods.price_tag}" placeholder="价格标签"></td>
                            <td class="td3"></td>
                        </tr>
                        <!-- 开启分销模式时 -->
                        <tr>
                            <td class="td1"><label for="self_fee_ratio"><span class="must-tag">*</span>一级佣金系数</label></td>
                            <td class="td2">
                                <input type="text" id="self_fee_ratio" name="self_fee_ratio" value="{$goods.self_fee_ratio}" placeholder="一级佣金系数"></td>
                            <td class="td3"></td>
                        </tr>
                        <tr>
                            <td class="td1"><label for="parent_fee_ratio"><span class="must-tag">*</span>二级佣金系数</label></td>
                            <td class="td2">
                                <input type="text" id="parent_fee_ratio" name="parent_fee_ratio" value="{$goods.parent_fee_ratio}" placeholder="二级佣金系数"></td>
                            <td class="td3"></td>
                        </tr>
                        <!--当前商品为统一规格-->
                        <tr  class="{if $goods.standard neq 0}hidden{/if}">
                            <td class="td1"><label for="inventory"><span class="must-tag">*</span>商品库存</label></td>
                            <td class="td2"><input type="text" id="inventory" name="inventory" value="{$goods.inventory}" placeholder="商品库存"></td>
                            <td class="td3"></td>
                        </tr>
                        <tr>
		                    <td class="td1">商家承诺<label class="must-tag">*</label></td>
		                    <td class="td2">
				                {foreach $promiseList as $key=>$promise}
				                <input name="pids[]"  class="my-icheckbox" type="checkbox" {if in_array($promise.id,$pidsArr)}checked{/if} value="{$promise.id}"/> {$promise.content}<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
				                {if ($key+1)%5 eq 0}
				                </br>
				                {/if}
				                {/foreach}
		                        </td>
		                        <td class="td3"></td>
		                    </tr>
                        <tr>
                            <td class="td1"><label for="salequantity"><span class="must-tag">*</span>商品销量</label></td>
                            <td class="td2"><input type="text" id="salequantity" name="sale_quantity"
                                                   placeholder="商品销量" value="{$goods.sale_quantity}"></td>
                            <td class="td3"></td>
                        </tr>

                        <tr>
                            <td class="td1"><label for="unit"><span class="must-tag">*</span>商品单位</label></td>
                            <td class="td2">
                            	<select id="unit" name="unit" class="select-normal">
                           		{if $unitsList}
                               		{foreach $unitsList as $unit}
                               		<option {if $unit.name eq $goods.unit}selected{/if}>{$unit.name}</option>
                               		{/foreach}
                               		{else}
                            		<option {if $goods.unit eq '件'}selected{/if}>件</option>
                            		<option {if $goods.unit eq '斤'}selected{/if}>斤</option>
                            		<option {if $goods.unit eq '箱'}selected{/if}>箱</option>
                            		<option {if $goods.unit eq '桶'}selected{/if}>桶</option>
                            		<option {if $goods.unit eq '盒'}selected{/if}>盒</option>
                            		<option {if $goods.unit eq '袋'}selected{/if}>袋</option>
                            		<option {if $goods.unit eq '个'}selected{/if}>个</option>
                            		<option {if $goods.unit eq '米'}selected{/if}>米</option>
                            		<option {if $goods.unit eq '张'}selected{/if}>张</option>
                            		<option {if $goods.unit eq '听'}selected{/if}>听</option>
                            		<option {if $goods.unit eq '罐'}selected{/if}>罐</option>
                            		{/if}
                            	</select>
                            </td>
                            <td class="td3"></td>
                        </tr>
                        <tr class="hidden">
                            <td class="td1"><label for="simpledesc"><span class="must-tag">*</span>商品简述</label></td>
                            <td class="td2"><input type="text" value="{$goods.simple_desc}" id="simpledesc" name="simple_desc" placeholder="商品简述"></td>
                            <td class="td3"></td>
                        </tr>
                        <tr class="hidden">
                            <td class="td1"><label for="share_total"><span class="must-tag">*</span>分享次数</label></td>
                            <td class="td2"><input type="text" id="share_total" name="share_total" value="{$goods.share_total}" placeholder="分享次数"></td>
                            <td class="td3"></td>
                        </tr>
                        <tr>
                            <td class="td1"><label for="sortnum"><span class="must-tag">*</span>排序系数</label></td>
                            <td class="td2"><input type="text" id="sortnum" name="sort_num" value="{$goods.sort_num}" placeholder="排序系数"></td>
                            <td class="td3"></td>
                        </tr>
                        <tr class="hidden">
                            <td class="td1"><label for="sortnum"><span class="must-tag">*</span>商品信息</label></td>
                            <td class="td2">
                                {if $goods.info}
                                {foreach $goods.info as $per}
                                <div class="goods-info">
                                    <input type="text" class="info-name" name="info_name[]" placeholder="信息名称" value="{$per.name}">
                                    <input type="text" class="info-value" name="info_value[]" placeholder="信息内容" value="{$per.value}">
                                    <button class="btn btn-danger btn-xs deleteInfo">删除</button>
                                    <button class="btn btn-info btn-xs addInfo">添加</button>
                                </div>
                                {/foreach}
                                {else}
                                <div class="goods-info">
                                    <input type="text" class="info-name" name="info_name[]" placeholder="信息名称" value="">
                                    <input type="text" class="info-value" name="info_value[]" placeholder="信息内容" value="">
                                    <button class="btn btn-danger btn-xs deleteInfo">删除</button>
                                    <button class="btn btn-info btn-xs addInfo">添加</button>
                                </div>

                                {/if}
                            </td>
                            <td class="td3"></td>
                        </tr>
                        <tr>
                            <td class="td1"><label><span class="must-tag">*</span>商品状态</label></td>
                            <td class="td2">
                                <label> <input type="radio" name="updown" value="1" {if $goods.updown eq '1'}checked{/if}> 上架</label>
                                <label> <input type="radio" name="updown" value="0"  {if $goods.updown eq '0'}checked{/if}>下架</label>
                            </td>
                            <td class="td3"></td>
                        </tr>
                        <tr>
                            <td class="td1"><label><span class="must-tag">*</span>首页推荐</label></td>
                            <td class="td2">
                                <label> <input type="radio" name="recommend" value="0" {if $goods.recommend eq '0'}checked{/if}> 不推荐</label>
                                <label> <input type="radio" name="recommend" value="1"  {if $goods.recommend eq '1'}checked{/if}>推荐</label>
                            </td>
                            <td class="td3"></td>
                        </tr>
                         <tr class="hidden">
                                <td class="td1"><label><span class="must-tag">*</span>是否参与打折</label></td>
                                <td class="td2">
                                    <label> <input type="radio" name="is_discount" value="0" {if $goods.is_discount eq 0}checked {/if}>不参与</label>&nbsp;&nbsp;
                                    <label> <input type="radio" name="is_discount" value="1" {if $goods.is_discount eq 1}checked {/if}>参与</label>
                                </td>
                                <td class="td3"></td>
                            </tr>
                             <tr class="need-discount {if $goods.is_discount eq 0 || true}hidden{/if}">
                                <td class="td1"><label for="pids"><span class="must-tag">&nbsp;&nbsp;*</span>折扣分类</label></td>
                                <td class="td2">
                                {foreach $discountCategoryInfo as $key=>$promise}
                                          <label class="for-right"><input name="discountCategoryId[]" style="margin:0" class="my-icheckbox" type="checkbox" value="{$promise.id}" {if $promise.checked}checked{/if} />{$promise.name}</label>&nbsp;&nbsp;
                                          {if ($key+1)%5 eq 0}</br>{/if}
		                              {/foreach}
                                    <input type="hidden" name="oldDiscountCategoryId" value="{$oldDiscountCategoryId}">
                                </td>
                                <td class="td3"></td>
                           </tr>
                        <tr>
                            <td class="td1">
                                <label for="buynote"><span class="must-tag">*</span>购物须知</label>
                            </td>
                            <td class="td2">
                                <!-- umeditor -->
                                <script type="text/plain" id="buynote" name="buy_note" style="width:780px;height:200px;">{$goods.buy_note}</script>
                                <script type="text/javascript">
                                    //实例化编辑器
                                    var um = UM.getEditor('buynote');
                                </script>
                                <!-- /umeditor -->
                            </td>
                            <td class="td3"></td>
                        </tr>
                        <tr>
                            <td class="td1">
                                <label for="detaildesc"><span class="must-tag">*</span>详情描述</label>
                            </td>
                            <td class="td2">
                                <!-- umeditor -->
                                <script type="text/plain" id="detaildesc" name="detail_desc" style="width:780px;height:200px;">{$goods.detail_desc}</script>
                                <script type="text/javascript">
                                    //实例化编辑器
                                    var um = UM.getEditor('detaildesc');
                                </script>
                                <!-- /umeditor -->
                            </td>
                            <td></td>
                        </tr>
                        <tr>
                            <td>

                            </td>
                            <td>
                                <input type="hidden" id='id' name="id" value="{$goods.id}">
                                <input type="hidden" id='addGroups' name="add_groups" value="">
                                <input type="hidden" id='addProperty' name="add_property" value="0">
                                <!--0为统一规格,1为多规格-->
                                <button type="button" class="btn btn-success btn-md" id='save'>提交</button>
                                <button type="button" class="btn btn-default btn-md" id="back">返回</button>
                            </td>
                            <td></td>
                        </tr>
                    </table>

                </form>
            </div>
        </div>
    </div>
</div>

<!-- 页脚 -->
{include file="common/page/footer"}

<script type="text/javascript" src="__static__/js/form/jquery.form.js"></script>
<script type="text/javascript" src="__static__/js/form/jquery.validate.js"></script>
<script type="text/javascript" src="__static__/js/form/jquery.validate.extend.js"></script>
<script type="text/javascript" src="__app__/admin/view/StoreGoods/editGoods/editGoods.js"></script>
</body>
</html>
